home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / word / tblnmbr.zip / TBLNMBR.RTF
Text File  |  1991-07-31  |  5KB  |  85 lines

  1. {\rtf1\ansi \deff0{\fonttbl{\f0\froman Tms Rmn;}{\f1\fdecor Symbol;}{\f2\fswiss Helv;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;
  2. \red255\green255\blue0;\red255\green255\blue255;}{\stylesheet{\fs20 \snext0 Normal;}}{\info{\title Auto Table Numbering}{\subject Row Numbering}{\author Kevin E. Nechodom}{\keywords Tables, merge}
  3. {\doccomm AutoTableNumber will prompt for a column heading, a number with which to start, and an increment value.  It's best use is to number a large table in order to see which records to print.}{\operator Kevin E. Nechodom}
  4. {\creatim\yr1991\mo7\dy31\hr8\min44}{\revtim\yr1991\mo7\dy31\hr11\min8}{\version3}{\edmins100}{\nofpages1}{\nofwords0}{\nofchars0}{\vern8351}}\widowctrl\ftnbj \sectd \linex0\endnhere \pard\plain \tqc\tx4320\tqr\tx8640 \fs20 \tab {\fs28 AutoNumberTable 1.0
  5. }\tab 07/31/91
  6. \par \pard \sb240 Kevin Nechodom\line University of Utah CSSRD/STACC\line 420 Chipeta Suite 220\line Salt Lake City, UT  84108\line nechodom@cc.utah.edu
  7. \par AutoNumberTable is a macro to number table rows.  While I was generating form letters from a table of 359 merge records, I discovered that there was no clean way to find out what row I was on so that I could merge just that one record.  
  8. This macro will insert a column at the beginning of the row, label the top row with a designated heading (defaults to {\b AutoNumber}), then start numbering from the next row with a specified start numberand increment (defaults to {\b 1} and {\b 1}, re
  9. spectively).
  10. \par \pard \sb240 To start this macro, you must first click anywhere within the table you want numbered.  It will bring up a dialog box querying for the header, start number and increment.
  11. \par Not being a Word for Windows Wonder Wizard, I don't have this as an auto-install procedure.  To install:
  12. \par \pard \fi-360\li720 1)\tab Copy the whole macro onto the Clipboard.
  13. \par 2)\tab Select {\ul M}acro {\ul E}dit.
  14. \par 3)\tab Type in the macro name "AutoNumberTable".
  15. \par 4)\tab Click {\b OK}.
  16. \par 5)\tab Delete the text on the macro screen.
  17. \par 6)\tab Paste the macro text from the Clipboard.
  18. \par 7)\tab Close the macro edit screen and save changes.
  19. \par \pard \fi-360\li720 8)\tab At this point, the macro may be assigned to a menu and/or a key sequence (I use {\b Shift+Ctrl+R}).
  20. \par \pard \sb240 For completeness, I suppose I should tell you:  1)  no warranties, 2)  no registration, 3)  no restrictions on copying, 4)  modifications may be made as long as the University of Utah is mentioned in the banner.
  21. \par \pard \sb240 (select from the line below to the bottom, and copy into the clipboard)
  22. \par \pard Sub MAIN
  23. \par 
  24. \par ' Setup of Dialog Box to get Column Name, Numbering Start and Step Size
  25. \par Begin Dialog UserDialog 280, 150
  26. \par Text 10, 6, 260, 12, "AutoNumberTable 1.0  Kevin Nechodom"
  27. \par Text 10, 18, 260, 12, "University of Utah, CSSRD/STACC, 1991"
  28. \par Text 10, \tab 44, \tab 207, \tab 12, "Column Heading:"
  29. \par \tab TextBox 150,\tab 42, \tab 120, \tab 15, .Field$
  30. \par Text 10, \tab 66, \tab 207, \tab 12, "Start Numbering at:"
  31. \par \tab TextBox 150, \tab 64, \tab 24, \tab 15, .RowNumber
  32. \par Text 10, \tab 88, \tab 207, \tab 12, "Step Numbering by:"
  33. \par \tab TextBox 150,\tab 86, \tab 24, \tab 15, .RowOffset
  34. \par OKButton 45, 120, 80, 20
  35. \par CancelButton 150, 120, 80, 20
  36. \par End Dialog
  37. \par Dim Dlg As UserDialog
  38. \par 
  39. \par ' Test to See if we are within a table.
  40. \par On Error Goto BadStart
  41. \par PrevCell
  42. \par 
  43. \par ' Set defaults
  44. \par On Error Goto Finish
  45. \par Dlg.Field$ = "AutoNumber"
  46. \par Dlg.RowNumber = "1"
  47. \par Dlg.RowOffset = "1"
  48. \par Dialog Dlg
  49. \par 'Use Return values
  50. \par Field$ = Dlg.Field$
  51. \par RowNumber = Val(Dlg.RowNumber)
  52. \par RowOffset = Val(Dlg.RowOffset)
  53. \par 
  54. \par 'Insert Column on Left Side
  55. \par StartOfRow
  56. \par EditTable .Modify = 1, .ShiftCells = 0, .Insert
  57. \par 
  58. \par 'Insert Column Heading
  59. \par Insert Field$
  60. \par 
  61. \par 'Insert Row Numbers
  62. \par LineDown 1
  63. \par ValidCell = 1
  64. \par While ValidCell <> 0
  65. \par \tab On Error Goto ErrorTrap
  66. \par \tab Num$ = Str$(Int(RowNumber))
  67. \par \tab Insert Right$(Num$, Len(Num$) - 1)
  68. \par \tab LineDown 1
  69. \par \tab RowNumber = RowNumber + RowOffset
  70. \par \tab ValidCell = NextCell()
  71. \par \tab Prev = PrevCell()
  72. \par \tab Wend
  73. \par Goto Finish
  74. \par 
  75. \par BadStart:
  76. \par MsgBox("Must be within a Table to start Numbering")
  77. \par Goto Finish
  78. \par 
  79. \par ErrorTrap:
  80. \par If Err <> 509 Then Error Err
  81. \par 
  82. \par Finish:
  83. \par End Sub
  84. \par 
  85. \par }